<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<form id="form_documentacao"
	action="<?php echo url_for('documentacao/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id_documento='.$form->getObject()->getIdDocumento() : '')) ?>"
	method="post"
	<?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
	<?php if (!$form->getObject()->isNew()): ?> <input type="hidden"
	name="sf_method" value="put" /> <input type="hidden"
	name="id_documento"
	value="<?php echo $form->getObject()->getIdDocumento() ?>" /> <?php endif; ?>
	<?php echo $form->renderHiddenFields() ?>
	<?php echo $form->renderGlobalErrors() ?>
	
	<table class="form">
		<tbody>
			<tr>
				<th><?php echo $form['id_tipo_documento']->renderLabel() ?></th>
				<td>
					<?php echo $form['id_tipo_documento'] ?> <?php echo form_error('documentacao[id_tipo_documento]'); ?>
					<?php include_component('tipo_documento', 'botaoAdicionar', array('name' => 'documento_')); ?>
				</td>
			</tr>
			<tr>
				<th><?php echo $form['id_modelo_documento']->renderLabel() ?></th>
				<td><?php echo $form['id_modelo_documento'] ?> <?php echo form_error('documentacao[id_modelo_documento]'); ?>
				</td>
			</tr>
			<tr>
				<th><?php echo $form['ds_documento']->renderLabel() ?></th>
				<td><?php echo $form['ds_documento'] ?> <?php echo form_error('documentacao[ds_documento]'); ?>
				</td>
			</tr>
		</tbody>
	</table>
</form>

<?php
	comandos_form(
		link_to(
			':: Listar ::',
			'documentacao/list',
			array('class' => 'btn')
		),
		button_to_function(
			':: Salvar ::',
			"$('#form_documentacao').submit()",
			array('class' => 'btn btn-primary')
		)
	);
?>